﻿using System;
using System.Drawing;
using System.ComponentModel;
using System.Drawing.Design;
using SedionFormDesigner.CusControls.TypeEditor;
using SedionFormDesigner.CusControls.ComboBox;

namespace SedionFormDesigner.CusControls
{
    public class BD_ComboBox : System.Windows.Forms.ComboBox
    {
        #region 属性:外观

        private float _fontsize = 9;//字体大小
        private bool _fontbold = false;//是否粗体
        private bool _fontitalic = false;//是否斜体
        private String _name = String.Empty;

        [Category("设计")]
        [ReadOnly(true)]
        public String NewName
        {
            get
            {
                _name = _name == String.Empty ? base.Name : _name;
                return _name;
            }
            set
            {
                _name = value;
                base.Name = _name;
            }
        }

        [Category("外观")]
        public float FontSize
        {
            set { _fontsize = value; FontChange(); }
            get { return _fontsize; }
        }

        [Category("外观")]
        public bool FontBold
        {
            set { _fontbold = value; FontChange(); }
            get { return _fontbold; }
        }

        [Category("外观")]
        public bool FontItalic
        {
            set { _fontitalic = value; FontChange(); }
            get { return _fontitalic; }
        }

        void FontChange()
        {
            if (_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold | FontStyle.Italic);
            else if (_fontbold && !_fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Bold);
            else if (!_fontbold && _fontitalic)
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize, FontStyle.Italic);
            else
                base.Font = new Font(base.Font.FontFamily.Name, _fontsize);
        }

        #endregion

        private String _sql;

        [Category("杂项")]
        [Description("数据源\r\n唯有选择操作类型为'绑定数据库'方有效")]
        [Browsable(true)]
        [Editor(typeof(DataSourceEditor), typeof(UITypeEditor)), Localizable(true)]
        public String SQL
        {
            get { return _sql; }
            set { _sql = value; }
        }

        private Autobing _autoBind;
        public Autobing AutoBind
        {
            set { this._autoBind = value; }
            get { return this._autoBind; }
        }
    }
}
